# -*- coding: utf-8 -*-
"""
@Author: Logan
@Date:   2025/6/28 15:13
@Description: 
"""
import yaml
from common.tools import abs_path, get_project_path, sep


class GetConf:
    def __init__(self):
        """
        初始化读取yaml文件
        """
        with open(abs_path(get_project_path(), sep(['config', 'environment.yaml'])), 'r',
                  encoding='utf-8') as f:
            self.env = yaml.load(f, Loader=yaml.FullLoader)

    def get_username_password(self, user):
        """
        获取用户账号密码
        :return:
        """
        return self.env["user"][user]['username'], self.env["user"][user]['password']

    def get_url(self):
        """
        获取访问url
        :return:
        """
        return self.env['url']

    def get_force_wait_time(self):
        """
        获取强制等待时间
        :return:
        """
        return self.env['force_wait_time']

    def get_mysql_config(self):
        """
        获取数据库连接信息
        :return:
        """
        return self.env['mysql']

    def get_redis(self):
        return self.env['redis']

    def get_dingding_webhook(self):
        return self.env["dingding_group"]["webhook"]

